<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
	<!--	<script type="text/javascript">
//			var BtnClassname="class open          hhh      ".replace(/open|close/g,"");
//			var lll=BtnClassname.replace(/\s+/g," ")//2个
//			BtnClassname
//			console.log(BtnClassname);
//			console.log(lll);
	     function foo(){
	     	console.log("name: ",this.name);
	     }
	     
	     foo.prototype.softBind = function(obj){
	     	this.name =obj.name;
	     	return this.constructor;
	     }
	     Object.prototype.foo =foo;
	     var foo =new foo();
		//console.log(foo.softBind);
	     var obj = {name:'obj'},obj2 = {name:'obj2'},obj3 = {name:'obj3'};
	     var fooOBJ = foo.softBind(obj);
	     fooOBJ();//输出 name：obj
	     obj2.foo = foo.softBind(obj);
	     obj2.foo()//输出 name：obj2
	     //fooOBJ.call(obj3);//输出 name:obj3
	     //setTimeout(obj2.foo,1000)//输出name:obj
		</script>-->
		<!--<script type="text/javascript">
			function square(i) {
			    return i * i;
			}
			
			function dubble(i) {
			    return i *= 2;
			}
			
			function map(handeler, list) {
			    return list.map(handeler);
			}
			
			// 数组的每一项平方
			console.log(map(square, [1, 2, 3, 4, 5]));
//			map(square, [1, 2, 3, 4, 5]);
//			map(square, [6, 7, 8, 9, 10]);
//			map(square, [10, 20, 30, 40, 50]);
//			// ......
//			
//			// 数组的每一项加倍
//			map(dubble, [1, 2, 3, 4, 5]);
//			map(dubble, [6, 7, 8, 9, 10]);
//			map(dubble, [10, 20, 30, 40, 50]);
		</script>-->
		<script type="text/javascript">
//			api1( "myApp", "xiaoming", "小明");
//			api1( "myApp", "xiaohong", "小红");
//			api1( "myApp", "xiaogang", "小刚");
//			
//			let myApi1 = function(uid, nickname){
//			    api1( "myApp", uid, nickname);
//			}
//			myApi1("xiaoming", "小明");
//			myApi1("xiaohong", "小红");
//			myApi1("xiaogang", "小刚");
//			
//			let myApi2 = function(token, uid){
//			    api2( "myApp", token, uid);
//			}
//			myApi2("token1", "xiaoming");
//			myApi2("token2", "xiaohong");
//			myApi2("token3", "xiaogang");
//		
//
//			let getMyApi = function(api){
//			    return function(p1, p2){
//			        api("myApp", p1, p2)
//			    }    
//			}
//			let myApi1 = getMyApi(api1)
//			let myApi2 = getMyApi(api2)
//			let myApi3 = getMyApi(api3)
//			
//			
//			let getMyApi2 = function(api){
//			    return function(p2){
//			        api("myApp", "myAppName", p2)
//			    }    
//			}
//			
//			let myApi4 = getMyApi2(api4)
//			let myApi5 = getMyApi2(api5)
//			let myApi6 = getMyApi2(api6)
			
			function api1(id,uid,nickname){
				console.log(id+"---"+uid+"----"+nickname);	
			}
			
			let generalGetMyApi = function(api) {
			    //把函数和需要固定住的参数都传递进来
			    console.log(arguments);
			   let settledArgs = [].splice.call(arguments, 1);
			    console.log(arguments);
			    //返回一个新的函数，这个函数包含了已经固定住部分参数，并且传入一些易变的参数
			    return function() {
			        //将不变的参数和易变的参数重新传进这个函数再执行
			        let mutableArguments = arguments;
			         console.log(arguments);
			         api.call(null, [].concat.apply(settledArgs, mutableArguments));
			    }
			}
			
			let myApi1 = generalGetMyApi(api1, "myApp1");
				myApi1("xiaoming", "小明");
				//myApi1("xiaohong", "小红");
				//myApi1("xiaogang", "小刚");
//		var hh = generalGetMyApi(woqu,"锋","云");
//		hh("wo","qu")
//		function woqu (ary1,ary2,ary3){
//			console.log(ary1);
//			console.log(ary2);
//			console.log(ary3);
//		}
		</script>
	</body>
</html>
